<template>
  <div class="con">
      <div class="header">
          <van-nav-bar
          class="head"
            title="热销排行"
            left-text="返回"
            left-arrow
            @click-left="onClickLeft"
/>
      </div>
      <main>
          <div class="title">
              <h2>今日人气榜</h2>
              <p>人气爆棚的热销商品,爆款推荐</p>
          </div>
          <div class="goods-list">
              <ul>
                  <li>
                      <p class="rank"><img src="../assets/1.gif" alt=""></p>
                      <figure>
                          <img src="../assets/s1.gif" alt="">
                          <figcaption>
                             <p>燕之坊 墨江胭脂紫米</p> 
                             <span>￥233</span>
                          </figcaption>  
                      </figure>
                      <div>立即购买</div>
                  </li>
                   <li>
                      <p class="rank"><img src="../assets/1.gif" alt=""></p>
                      <figure>
                          <img src="../assets/s1.gif" alt="">
                          <figcaption>
                             <p>燕之坊 墨江胭脂紫米</p> 
                             <span>￥233</span>
                          </figcaption>  
                      </figure>
                      <div>立即购买</div>
                  </li>
                   <li>
                      <p class="rank"><img src="../assets/1.gif" alt=""></p>
                      <figure>
                          <img src="../assets/s1.gif" alt="">
                          <figcaption>
                             <p>燕之坊 墨江胭脂紫米</p> 
                             <span>￥233</span>
                          </figcaption>  
                      </figure>
                      <div>立即购买</div>
                  </li>
                   <li>
                      <p class="rank"><img src="../assets/1.gif" alt=""></p>
                      <figure>
                          <img src="../assets/s1.gif" alt="">
                          <figcaption>
                             <p>燕之坊 墨江胭脂紫米</p> 
                             <span>￥233</span>
                          </figcaption>  
                      </figure>
                      <div>立即购买</div>
                  </li>
              </ul>
          </div>
          <div class="more-goods">
            <h2>更多热销好物</h2>
            <van-tabs @click="tab1" >
                <van-tab v-for="(title,i) in tit" :title="title" :key='i' @click="detail(title.pid)">
                     <ul class="more-goods-con">
                        <li v-for="(item,i) in list " :key='i'>
                            <div class="more-good-wrap">
                                <img :src="item.pimg" alt="">
                            </div>
                            <h3>{{item.pname}}</h3>
                            <p>￥{{item.pprice}}</p>
                         </li>
                    </ul>
                </van-tab>
            </van-tabs>
          </div>
      </main>
  </div>
</template>

<script>
import * as api from '../../api/getproductlist'
export default {
    name:'Rank',
    data(){
        return {
            list:[],
            i:0,
            tit:['食品饮料','服饰鞋包','保健滋补','美妆个护','家具家装']
        }
    },
    methods:{
      onClickLeft(){
          this.$router.go(-1)
      },
      tab1(name){
        this.i=name+1;
         api.getclasspro({classid:this.i}).then(data=>{
                this.list=data.data.data
            })
      } ,
      detail(id){
        this.$router.push("/detailpro/" + id);
      }
     
    },
        mounted(){
            api.getclasspro({classid:this.i+1}).then(data=>{
                this.list=data.data.data
            })
        }
}
</script>

<style scoped>
.more-goods-con .more-good-wrap{
   width: 100%;
   height: 140px;
   margin-top: 15px;
}
.more-goods-con .more-good-wrap img{
   display: inline-block;
     width: 100%;
   height: 100%;
   background: red
}
.more-goods-con {
   width: 100%;
   display: flex;
   flex-wrap: wrap;
   justify-content: space-between;
}
.more-goods-con li h3,p{
   margin: 0
}
.more-goods-con li:first-child{
    margin-top: 0
}
.more-goods-con li:nth-child(2){
    margin-top: 0
}
.more-goods-con li p{
   width: 100%;
   text-align: left;
   color: red;
   font-size: 12px;
   height: 30px;
}
.more-goods-con li h3{
     width:100%;
    word-break:break-all;
    text-overflow:ellipsis;
    display:-webkit-box;
    -webkit-box-orient:vertical;
    -webkit-line-clamp:2;
    overflow:hidden;
    font-weight: normal;
    color: #323232;
    margin-bottom: 10px
}
.more-goods-con li{
   width: 50%;
   border: 1px solid #f3f3f3;
   height: 230px;
   padding: 10px 6px;
   box-sizing: border-box;
   border-right:0;
   margin-top:-1px ;
   display: flex;
   flex-direction: column;
   align-items: center;
  justify-content:start;
  padding-bottom: 0
}
.more-goods-con li:nth-child(odd){
   border-left:0 
}
.more-goods{
    margin-top: 8px;
    background: #fff
}
.more-goods h2{
    height: 40px;
    line-height: 40px;
    text-align: center;
    font-size: 16px
}
.goods-list ul{
    background: #fff
}
.goods-list ul li{
    margin: 0 18px;
    border: 1px solid #f3f3f3;
    padding: 0 3px;
    margin-bottom: 10px;
    padding-bottom: 15px
}
.goods-list ul li figure{
    display: flex;
}
.goods-list ul li figure img{
    width:112px;
    display: block ;
    margin-left: 20px;
    margin-top: -10px;
    margin-right: 10px
}
.goods-list ul li figure figcaption{
    display: flex;
    flex-direction: column;
}
.goods-list ul li figure figcaption p{
    font-size: 14px;
    margin-top: 15px;
    margin-bottom: 50px
}
.goods-list ul li figure figcaption span{
    color: red;
    font-size: 14px;
    font-weight: 600;
}
.goods-list ul li div{
    width: 90px;
    height: 35px;
    background: red;
    text-align: center;
    line-height: 35px;
    color: #fff;
    border-radius: 3px;
    font-size: 14px;
    margin-top: 20px;
    margin-left: 240px
}

.goods-list ul li:nth-child(odd) .rank{
    height: 40px;
    line-height: 40px;
    text-align: right;
}
.goods-list ul li:nth-child(even) .rank{
    height: 40px;
    line-height: 40px;
    text-align: left;
}
.goods-list ul li .rank img{
    height: 35px;
}
.con{
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f1f1f3
}
main{
    flex: 1;
    overflow: auto;
    background: #f1f1f3
}
.title{
    height: 90px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #fff
}
.title h2{
    margin-bottom: 10px
}
h2,h3,h4,p,figure,dl{
    margin: 0;
}
.van-nav-bar__text{
    color: black
}
.van-icon {
    color: #000
}

</style>